<?php


define('MANS_', true);

require(dirname(__FILE__) . '/includes/init.php');

$cat_id = !empty($_REQUEST['cat_id'])? intval($_REQUEST['cat_id']) :0;
$size = !empty($_REQUEST['size'])? intval($_REQUEST['size']) : 10;

$start = $page*$size;




$in_cat_user = @($_SESSION['user_info']['cat_id']== $cat_id) || 0;
$sm->assign('is_cat_admin',	$User->isCatAdmin($cat_id));
$sm->assign('in_cat_user',	$in_cat_user);
$sm->assign('isWished',$User->iSwished($cat_id,2));
if($cat_id)
{
    $cat = $Cate->catInfo($cat_id);

   if(!empty($_GET['admin']) && $_GET['admin']=='1')
   {

		$user_info = $User->userInfo($cat['mag_id']);
		$User->userSession($user_info);

		$Main->msg("","category.php?cat_id=$cat_id");
   }


   $cat = $Other->xqCatInfo($cat);


   if(!preg_match("#".$cat['match']."#",$req))
   {
			//$Main->url301($cat['url']);
   }
    if(!$sm->isCached('category.htm',$cache_id))
	{



		$cat_pg = CAT_NAME.'-'.$cat_id;
		$ids = $Goods->ids($cat_id);


		$price = $Goods->priceLimit();
		$join = ' (cat_id='.join($ids,' or cat_id=').')';

		$where = " where  $join $price  ".GOODS_DELETE_SHOW." order by haoping desc,sort_order asc";

		$count = $Main->counts("select count(*) from goods $where");
		$pager = $Main->pager($count,$size,"category.php?cat_id=$cat_id");





		$goods_list = $Goods->goodsList($start,$size,$where,',haoping');
		//print_r($goods_list);die();
	    $son_list = $Cate->categoryTree($cat_id,false,true);

		$sm->assign('son_list',	$son_list);
		$sm->assign('pagers',	$pager);

		$position = $Main->position($cat,CAT_NAME);
		$Main->assigns($position);
		$sm->assign('goods_list',	$goods_list);
		$sm->assign('cat',	$cat);

		$condition = @$_SESSION['search'];

		$sm->assign('price_limitd',@$condition['price_limitd']);



		$review = $User->reviewList(0,10," where id=$cat_id and type=1 ",true);
		$sm->assign('review',	$review);

		//print_r($review);die();
		$sm->assign('id',	$cat_id);
		$sm->assign('review_type',	1);
	}
	if($cat_id==JF_MALL_ID) //积分商城
	{
		//print_r($_SESSION['user_info']);die();
		$gold_log = $User->goldLog(0,10," where type=4 order by add_time desc");
		//print_r($gold_log);die();
		$sm->assign('gold_log',	$gold_log);
		$sm->display('category_jf.htm',$cache_id);
	}
	else
	{
		$sm->display('category.htm',$cache_id);
	}

}
else
{
	header("location:/error");
}

?>
